﻿//  -------------------- iSharePoint -------------------- //
// 
//  Company:	IT Complex, LLC
//  Project:	Smart.Documents
//  File name:	Const.cs
//  Developer:	Solomatov Igor
//  Created:	16.04.2012
// 
//  -------------------- iSharePoint -------------------- //

using System;
using System.Collections.Specialized;
using Microsoft.SharePoint;
using Smart.Common;

namespace Smart.Documents
{
	public static class Documents
	{
		// Resource file name Key
		public static string ResourceKey = "Smart.Documents";

		public static uint GetLang()
		{
			var web = SPH.GetWeb();

			return web != null ? web.Language : 1049;
		}

		public static SyncDictionary<string, string> LsD;

		public static string GetLocalizedString(string key)
		{
			if (string.IsNullOrEmpty(key))
				return key;

			var lang = GetLang();

			if (LsD == null)
				LsD = new SyncDictionary<string, string>(StringComparer.OrdinalIgnoreCase);

			var res = LsD[key + ":" + lang];

			if (res != null)
				return res;

			res = Microsoft.SharePoint.Utilities.SPUtility.GetLocalizedString("$Resources:" + ResourceKey + "," + key + ";", ResourceKey, lang);

			if (res != null)
			{
				if (res.StartsWith("$Resources", StringComparison.OrdinalIgnoreCase))
					H.LT("Resource not found: {0}", key);

				LsD[key + ":" + lang] = res;
			}

			return res;
		}

		public static string Localized(this string key)
		{
			return GetLocalizedString(key);
		}

		public static bool IsLocalized(this string key)
		{
			return key != null && key.StartsWith("$Resources", StringComparison.OrdinalIgnoreCase);
		}
	}

	public static class Const
	{
		public static class ListUrls
		{
			public const string Department = "Lists/Departments";
			public const string Employees = "Lists/Employees";
			public const string News = "Lists/Posts";
			public const string Category = "Lists/Categories";
			public const string Photos = "Lists/Photos";

			public const string Assignments = "Lists/Assignments";

			public const string WorkingSchedule = "Lists/WorkingSchedule";

			public const string Video = "/PublishingImages/";
		}

		public static class AmountField
		{
			public const string NdsFieldCalculationScriptUrl = "~/_layouts/Smart.Documents/ndscalculation.js";
		}

		public static class AttachmentsField
		{
			public const string AttachmentsFolderName = "Attachments";
		}

		public static class SubWebManager
		{
			public static class Features
			{
				public static Guid[] PublishingFeatureGuid
				{
					get { return new[] { new Guid("{22a9ef51-737b-4ff2-9346-694633fe4416}"), new Guid("6e37d7b0-32e4-4ea3-836b-aecb064b3927") }; }
				}
			}

			public static class EventNames
			{
				/// <summary>
				/// Setup new SPWeb content, args: string eventName, SPWeb web
				/// </summary>
				public const string SetupContent = "subwebmanager.setupcontent";

				/// <summary>
				/// Setup new SPWeb security, args: string eventName, SPWeb web
				/// </summary>
				public const string SetupSecurity = "subwebmanager.setupsecurity";
			}
		}

		public static class Assignments
		{
			public const string WorkingScheduleContentTypeId = "0x01020093AB4E8A46D74C298015B9FACE4F6B85";

			public const string AssignmentContentTypeId = "0x01080100B53F82F467B14F2E9DFD2DA17C2D211C";
			public const string AssignmentApproveContentTypeId = "0x01080100B53F82F467B14F2E9DFD2DA17C2D211C01";
			public const string AssignmentReadContentTypeId = "0x01080100B53F82F467B14F2E9DFD2DA17C2D211C02";

			public static class Cache
			{
				public const string WorkingScheduleKeyPrefix = "wsc.";

				public static readonly TimeSpan WorkingScheduleMinSlidingExpiration = new TimeSpan(0, 5, 0);
				public static readonly TimeSpan WorkingScheduleMinAbsoluteExpiration = new TimeSpan(0, 15, 0);
			}
		}

		public static class PrivateOffice
		{
			public const string PrivateOfficeServiceName = "PrivateOffice";

			public const string RenPrivateOfficeServiceName = "RenPrivateOffice";

			public const string DefinitionConfKey = "PrivateOffice.Definition";

			public const string SubRootFolderConfKey = "PrivateOffice.SubRootFolder.";

			public const string DefinitionCacheKey = "podc";
			public const string AssignmentsListCacheKey = "poalc";

			/// <summary>
			/// PrivateOffice public event names
			/// </summary>
			public static class EventNames
			{
				/// <summary>
				/// Setup assignments datatable, args: string eventName, DataTable dt
				/// </summary>
				public const string SetupAssignmentsDataTable = "PrivateOffice.SetupAssignmentsDataTable";

				/// <summary>
				/// Fill assignments datarow, args: string eventName, DataRow row, MetaWebScope mw, SPListItem item
				/// </summary>
				public const string FillAssignmentsDataRow = "PrivateOffice.FillAssignmentsDataRow";

				/// <summary>
				/// Setup documents datatable, args: string eventName, DataTable dt
				/// </summary>
				public const string SetupDocumentsDataTable = "PrivateOffice.SetupDocumentsDataTable";

				/// <summary>
				/// Fill documents datarow, args: string eventName, DataRow row, MetaWebScope mw
				/// </summary>
				public const string FillDocumentsDataRow = "PrivateOffice.FillDocumentsDataRow";
			}
		}

		public static class Guids
		{
			public const string EmptyPhotoUrl = "/_layouts/images/person.gif";
			public const string EmptyPhotoTitle = "Empty photo link";
			public const string ArraySeporator = ";#";
			public const string ArraySubSeporator = ",#";
			public const string TimeSeporator = ":";
			public const int DefaultNewsOnPage = 5;

			public static class OrgStructureInstance
			{
				public static readonly Guid Department = new Guid("{02493D83-468C-42aa-B92E-1D0856AE7434}");
				public static readonly Guid Chief = new Guid("{BB12B1C1-B387-11E0-8A2D-97944824019B}");
				public static readonly Guid User = new Guid("{5CB231B3-B389-11E0-BBB2-8F964824019B}");
			}

			public static class WorkingSchedule
			{
				public static readonly Guid Principal = new Guid("{52800C70-97DE-4379-9999-8A840154C6B8}");
				public static readonly Guid Level = new Guid("{4439D447-8C6D-412F-9999-0C41CAF9E782}");
			}

			public static class Department
			{
				public static readonly Guid RootDepartment = new Guid("{CD66300B-7F61-40EA-85C1-A3854AD8A4D0}");
				public static readonly Guid Head = new Guid("{BB12B1C1-B387-11E0-8A2D-97944824019C}");
			}

			public static class DepartmentUrl
			{
				public static Guid Group = new Guid("{A148B244-37F8-4A4E-9631-66CA3C77C629}");
			}

			public static class Post
			{
				public static Guid Annotation
				{
					get { return new Guid("{DAC4FC0D-A7FC-48B8-8F14-78CC010C066C}"); }
				}

				public static Guid NumComments
				{
					get { return new Guid("{e136aa19-e8d1-1b3c-a32c-aba3e58a971b}"); }
				}

				public static Guid ThumbnailPhoto
				{
					get { return new Guid("{83D1CAF6-9B9B-48CC-B884-4F6271A9156F}"); }
				}
			}

			public static class Employee
			{
				public static Guid ProfileLink
				{
					get { return new Guid("{F980C2B4-B387-11E0-8A2D-97944824019B}"); }
				}

				public static Guid Head
				{
					get { return new Guid("{BB12B1C1-B387-11E0-8A2D-97944824019B}"); }
				}

				public static Guid SPUserField
				{
					get { return new Guid("{5CB231B3-B389-11E0-BBB2-8F964824019B}"); }
				}

				public static Guid Department
				{
					get { return new Guid("{02493D83-468C-42aa-B92E-1D0856AE7434}"); }
				}

				public static Guid PhotoLink
				{
					get { return new Guid("{124B007E-CBC2-4592-B521-F1678DA25DE8}"); }
				}

				public static Guid EmployeeID
				{
					get { return new Guid("{043500D3-9D68-486D-B229-54DB1951C0E0}"); }
				}

				public static Guid Position
				{
					get { return new Guid("{CED4BF5B-FB42-4968-AF46-4071755966CD}"); }
				}

				public static Guid WorkPhone
				{
					get { return new Guid("{55D102F1-BA17-4143-B7CB-32B9578704B4}"); }
				}

				public static Guid MobilePhone
				{
					get { return new Guid("{A6734894-B387-11E0-9391-FF934824019B}"); }
				}

				public static Guid FullWorkPhone
				{
					get { return new Guid("{FD9B4E06-0EB5-46A4-AC71-EA61C98E389D}"); }
				}

				public static Guid WorkEmail
				{
					get { return new Guid("{E32584F0-B387-11E0-AA22-8D944824019B}"); }
				}

				public static Guid HireDate
				{
					get { return new Guid("{632BAE36-B388-11E0-9AC8-F3944824019B}"); }
				}

				public static Guid FiredDate
				{
					get { return new Guid("{874D157A-B388-11E0-AE7B-0E954824019B}"); }
				}

				public static Guid Office
				{
					get { return new Guid("{BD58BBE2-B388-11E0-B951-9A954824019B}"); }
				}

				public static Guid BirthDate
				{
					get { return new Guid("{8FD54DEC-B389-11E0-80F6-8E964824019B}"); }
				}

				public static Guid City
				{
					get { return new Guid("{1DA065E2-B389-11E0-BBB2-8F964824019B}"); }
				}
			}

			public static class DocumentType
			{
				public static readonly Guid DocumentContentTypeId = new Guid("{561C2475-0B1C-482D-9310-1C028EC14E82}");
			}

			public static class DocumentForm
			{
				public static readonly Guid Definition = new Guid("{AC126A1F-CC44-4CA6-A888-B6543CBB6BB4}");
				public static readonly Guid DocumentTypes = new Guid("{12008E43-7FB7-495C-B176-BD3FF476A379}");
				public static readonly Guid LibUrl = new Guid("{3C5944A4-87BA-433B-8E34-4CFDAFD3E79B}");
			}
		}


		public static class Fields
		{
			public static string Body_InternalName = "Body";
			public static Guid Body_Id = new Guid("{7662cd2c-f069-4dba-9e35-082cf976e170}");
			public static string QuestionLookup_InternalName = "QuestionLookup";
			public static Guid QuestionLookup_Id = new Guid("2E0CD070-78F5-4E9C-A596-9D7FDE5931CE");
			public static string BestAnswer_InternalName = "BestAnswer";
			public static Guid BestAnswer_Id = new Guid("{181EF5BB-1791-4F93-852B-BCFC3B51DA2B}");
			public static string CommentsQuestionLookup_InternalName = "CommentsQuestionLookup";
			public static Guid CommentsQuestionLookup_Id = new Guid("95d89725-eb97-428b-bc79-ee02ca8b724d");
			public static string CommentsAnswerLookup_InternalName = "CommentsAnswerLookup";
			public static Guid CommentsAnswerLookup_Id = new Guid("6E37B0FC-4C8D-4F46-8771-51B4964B85DC");
			public static string ViewsCounter_InternalName = "ViewsCounter";
			public static Guid ViewsCounter_Id = new Guid("{7CC88DF9-C967-4696-90FA-50721E3DE181}");
			public static string AnswersCounter_InternalName = "AnswersCounter";
			public static Guid AnswersCounter_Id = new Guid("{64C460A1-2D1C-4D03-B7AC-F0CF87C91951}");
			public static string VotesCounter_InternalName = "VotesCounter";
			public static Guid VotesCounter_Id = new Guid("{796DF97E-B622-4E43-AB2A-3418FA9221BA}");

			public static class WorkingSchedule
			{
				public const string EventDate = "EventDate";
				public const string EndDate = "EndDate";
				public const string RecurrenceID = "RecurrenceID";
			}
		}

		public static class FileProperties
		{
			public const string ContentType = "ContentType";

			public const string vti_title = "vti_title";

			public const string ImageCreateDate = "ImageCreateDate";

			public const string Description = "Description";
		}

		public static SPContentTypeId PictureAlbumCTId = new SPContentTypeId("0x0120000554a53112234c8397889b950a413b81");

		/// <summary>
		/// Templates
		/// </summary>
		public static class Templates
		{
			/// <summary>
			/// Templates library router key
			/// </summary>
			public const string LibTemplatesKey = "libs.templates";

			/// <summary>
			/// Converting templates library router key
			/// </summary>
			public const string LibConvertingTemplatesKey = "libs.convertingtemplates";


			/// <summary>
			/// Word templates
			/// </summary>
			public static class Word
			{
				/// <summary>
				/// Word templates
				/// </summary>
				public const string TemplateTypeName = @"word";

				/// <summary>
				/// Word templates library router key
				/// </summary>
				public const string TemplatesLibRouterKey = "libs.templates.word";

				/// <summary>
				/// Word instances library router key
				/// </summary>
				public const string InstancesLibRouterKey = "libs.instances.word";

				/// <summary>
				/// Required part of document variable definition
				/// </summary>
				public const string DOCVARIABLE = @"DOCVARIABLE";

				/// <summary>
				/// Postfix which is appending to name of document variables in table rows
				/// </summary>
				public const string DOCVARIABLE_POSTFIX = @"_{0}";

				/// <summary>
				/// Word Automation Services name
				/// </summary>
				public const string WordAutomationServicesNameConfigKey = @"Templates.Word.WordAutomationServicesName";

				/// <summary>
				/// Default value of Word Automation Services name
				/// </summary>
				public const string WordAutomationServicesNameDefaultValue = @"Word Automation Services";

				/// <summary>
				/// Path to the word templates formatter user control
				/// </summary>
				public const string CreateDocumentControlConfigKey = @"Templates.Word.CreateDocumentControl";

				/// <summary>
				/// Value for null and string.Empty variables
				/// </summary>
				public const string NullVariableValueConfigKey = @"Templates.Word.NullVariableValue";

				/// <summary>
				/// Default value for null and string.Empty variables
				/// </summary>
				public const string NullVariableValueDefaultValue = @" ";
			}
		}

		/// <summary>
		/// Router
		/// </summary>
		public static class Router
		{
			public const string DocumentRouterName = "DocumentRouter";

			/// <summary>
			/// Web router
			/// </summary>
			public static class Web
			{
				/// <summary>
				/// Configuration setting name
				/// </summary>
				public const string ConfigSettingName = @"Router.Settings";

				/// <summary>
				/// WebRouterService type name
				/// </summary>
				public const string ServiceName = @"WebRouterService";

				/// <summary>
				/// Tags using in template uri
				/// </summary>
				public static class Tags
				{
					/// <summary>
					/// Symbol surrounds the tag
					/// </summary>
					public const string TagSymbol = @"##";

					/// <summary>
					/// Name of the current web
					/// </summary>
					public const string WebName = @"web:name";

					/// <summary>
					/// Url of the current web
					/// </summary>
					public const string WebUrl = @"web:url";

					/// <summary>
					/// Field value of the current entity
					/// </summary>
					public const string Field = @"field:";
				}
			}
		}

		/// <summary>
		/// Converter values
		/// </summary>
		public static class Converter
		{
			/// <summary>
			/// Temp lib url
			/// </summary>
			public const string ConvertingTemplatesLib = "ConvertingTemplates";
		}

		/// <summary>
		/// Scope type names
		/// </summary>
		public static class ScopeNames
		{
			/// <summary>
			/// Organizational structure scope
			/// </summary>
			public const string OrgStructure = "OrgStructure";

			/// <summary>
			/// Documents scope
			/// </summary>
			public const string Documents = "Documents";

			/// <summary>
			/// Assignments scope
			/// </summary>
			public const string Assignments = "Assignments";

			/// <summary>
			/// Working schedule scope
			/// </summary>
			public const string WorkingSchedule = "WorkingSchedule";
		}

		/// <summary>
		/// Entity facade type names
		/// </summary>
		public static class FacadeNames
		{
			/// <summary>
			/// Orgstructure departments facade
			/// </summary>
			public const string OrgStructureDepartments = "orgstructure.departments";

			/// <summary>
			/// Orgstructure employees facade
			/// </summary>
			public const string OrgStructureEmployees = "orgstructure.employees";

			/// <summary>
			/// Orgstructure departments urls facade
			/// </summary>
			public const string OrgStructureDepartmentsUrls = "orgstructure.departmentsurls";

			public const string DocumentTypes = "documents.documenttypes";
			public const string RequiredDocumentTypes = "documents.requireddocumenttypes";
			public const string DocumentForms = "documents.documentforms";
			public const string ApprovalDecisions = "documents.approvaldecisions";
			public const string ApprovalStatuses = "documents.approvalstatuses";
			public const string ExecutionStatuses = "documents.executionstatuses";

			/// <summary>
			/// Assignments facade name
			/// </summary>
			public const string Assignments = "assignments.assignments";

			/// <summary>
			/// Working schedule facade name
			/// </summary>
			public const string WorkingSchedule = "assignments.workingschedule";

			/*
			public const string AssignmentsApprove = "assignments.assignmentsapprove";

			public const string AssignmentsRead = "assignments.assignmentsread";
			 */
		}

		/// <summary>
		/// Entity type names
		/// </summary>
		public static class EntityNames
		{
			/// <summary>
			/// WordTemplate entity
			/// </summary>
			public const string WordTemplate = "templates.wordtemplate";

			/// <summary>
			/// WordInstance entity
			/// </summary>
			public const string WordInstance = "templates.wordinstance";

			/// <summary>
			/// Department entity
			/// </summary>
			public const string OrgStructureDepartments = "orgstructure.departments";

			/// <summary>
			/// Employee entity
			/// </summary>
			public const string OrgStructureEmployees = "orgstructure.employees";

			/// <summary>
			/// Department web entity (Departments web urls)
			/// </summary>
			public const string OrgStructureDepartmentUrl = "departmentsurls.departmenturl";

			public const string DocumentType = "documents.documenttype";
			public const string RequiredDocumentType = "documents.requireddocumenttype";
			public const string DocumentForm = "documents.documentform";
			public const string BaseStatus = "documents.basestatus";

			/// <summary>
			/// Assignment web entity
			/// </summary>
			public const string Assignment = "assignments.assignment";

			/// <summary>
			/// WorkingSchedule web entity
			/// </summary>
			public const string WorkingSchedule = "assignments.workingschedule";

			/// <summary>
			/// AssignmentApprove web entity
			/// </summary>
			public const string AssignmentApprove = "assignments.assignmentapprove";

			/// <summary>
			/// AssignmentRead web entity
			/// </summary>
			public const string AssignmentRead = "assignments.assignmentread";
		}

		/// <summary>
		/// EventManager events
		/// </summary>
		public static class EventNames
		{
			/// <summary>
			/// PrivateOffice events
			/// </summary>
			public static class PrivateOffice
			{
				/// <summary>
				/// Load private office definition (args: PrivateOfficeSource, PrivateOfficeSource.PrivateOfficeDefinitionInfo)
				/// </summary>
				public const string LoadDefinition = "PrivateOffice.LoadDefinition";

				/// <summary>
				/// Load private office definition (renessans) (args: PrivateOfficeSource, PrivateOfficeSource.PrivateOfficeDefinitionInfo)
				/// </summary>
				public const string KRenLoadDefinition = "KRenPrivateOffice.LoadDefinition";
			}
		}
	}
}